/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ec;

import java.io.PrintStream;

/**
 *
 * @author alex
 */
public class ProduceAssembly {
    int labelcounter;
    PrintStream m_out;

    public ProduceAssembly(PrintStream out) {
        m_out=out;
        labelcounter=0;
    }

    public String NewLabel()
    {
        return "L"+labelcounter++;
    }
    public void PostLabel(String str)
    {
        m_out.println(str+":");
    }

     public void Emit(String str)
    {
        m_out.print("\t"+str);
    }

    public void EmitNoTab(String str)
    {
        m_out.print(str);
    }

        public void EmitNoTabln(String str)
    {
        EmitNoTab(str);
        m_out.println("");
    }
    public void Emitln(String str)
    {
        Emit(str);
        m_out.println("");
    }
    public void Allocate(String Name, String Val) {
        EmitNoTabln(Name + ":\tDC\t" + Val);
    }

    public void Branch(String label) {
        Emitln("Jump " + label);
    }

    public void BranchFalse(String label) {
        Emitln("On False goto"+label);
        
    }

    public void Clear() {
        Emitln("ClearPrimary");
    }

    public void ClearScreen() {
        Emitln("ClearScreen");
    }

    public void LoadConst(String str) {
        Emitln("LoadPrimary #" + str);
    }

    public void LoadVar(String str) {
        Emitln("LoadPrimary " + str);
    }

    public void Negate() {
        Emitln("NegatePrimary");
    }

    public void NotIt() {
        Emitln("NotPrimary");
    }

    public void Peek() {
        Emitln("Load the primary from where the primary points");
    }

    public void Poke() {
        Emitln("Store the primary where the top of stack points");
    }

    public void PopAdd() {
        Emitln("AddTopofStacktoPrimary");
    }

    public void PopAnd() {
        Emitln("And top of stack with A");
    }

    public void PopCompare() {
        Emitln("Compare top of stack with A");
    }

    public void PopDiv() {
        Emitln("DivideTopOfStackByPrimary");
    }

    public void PopMod() {
        Emitln("Modulo Top of stack / A");
    }

    public void Exp() {
        Emitln("Raise Top of stack to Primary");
    }
    public void PopMul() {
        Emitln("MultiplyTopOfStackWithPrimary");
    }

    public void PopOr() {
        Emitln("OR Top of stack with A");
    }

    public void PopSub() {
        Emitln("SubtractPrimaryFromTopOfStack");
    }

    public void PopXor() {
        Emitln("XOR top of stack with A");
    }

    public void PrintPrimary() {
        Emitln("PrintPrimary");
    }

    public void PushPrimary() {
        Emitln("PushPrimary");
    }

    public void SetEqual() {
        Emitln("Set A if compare was =");
    }

    public void SetGreater() {
        Emitln("Set A if compare was >");
    }

    public void SetGreaterOrEqual() {
        Emitln("Set A if compare was >=");
    }

    public void SetLess() {
        Emitln("Set A if compare was <");
    }

    public void SetLessOrEqual() {
        Emitln("Set A if compare was <=");
    }

    public void SetNEqual() {
        Emitln("Set A if compare was !=");
    }

    public void Store(String str) {
        Emitln("StorePrimary " + str);
    }

    public void AsmShiftLeft(){
        Emitln("Shift top of stack N times left. (N is in Primary)");
    }

    public void AsmShiftRight(){
        Emitln("Shift top of stack N times left. (N is in Primary)");
    }
}
